package cn.xpf.study.dao;

import cn.xpf.study.model.LessonItem;
import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * Create on 2021/5/13
 *
 * @author shuxinsheng@qiyi.com
 **/
@Mapper
public interface LessonItemMapper {

    String table = "lesson_item";

    @Select("select * from " + table + " where lessonId=#{lessonId}")
    List<LessonItem> findByLessonId(@Param("lessonId") int lessonId);

    @Select("select * from " + table)
    List<LessonItem> findAll();

    @Select("select * from " + table + " where lessonId=#{lessonId} limit 1")
    LessonItem findOne(@Param("lessonId") int lessonId);

    @Update("update " + table + " set content=#{lessonItem.content} where lessonId=#{lessonItem.lessonId}")
    void updateOne(@Param("lessonItem") LessonItem lessonItem);

    @Insert("insert into " + table + "(lessonId, content) values (#{lessonItem.lessonId},#{lessonItem.content})")
    void insertOne(@Param("lessonItem") LessonItem lessonItem);

}
